package cn.edu.nsmc.modules.sys.service.impl;

import cn.edu.nsmc.common.utils.R;
import cn.edu.nsmc.modules.sys.dao.SysWorksheetRecordDao;
import cn.edu.nsmc.modules.sys.entity.form.MaintenanceDataForm;
import cn.edu.nsmc.modules.sys.entity.vo.MaintenanceDataRecordVo;
import cn.edu.nsmc.modules.sys.entity.vo.MaintenanceDataRepairmanVo;
import cn.edu.nsmc.modules.sys.entity.vo.SysUserVO;
import cn.edu.nsmc.modules.sys.service.SysMaintenanceDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SysMaintenanceDataServiceImpl implements SysMaintenanceDataService {
    @Autowired
    private SysWorksheetRecordDao sysWorksheetRecordDao;

    @Override
    public R getList(MaintenanceDataForm maintenanceDataForm, Integer page, Integer size) {
        List<MaintenanceDataRepairmanVo> list = sysWorksheetRecordDao.getMaintenanceRepairmanList(page, size, maintenanceDataForm);
        Integer total = sysWorksheetRecordDao.getMaintenanceRepairmanNumber(maintenanceDataForm);
        Map<String,Object> data = new HashMap<>();
        data.put("list",list);
        data.put("total",total);
        data.put("status",sysWorksheetRecordDao.getStatusCount(maintenanceDataForm));
        data.put("type",sysWorksheetRecordDao.getTypeCount(maintenanceDataForm));
        return R.success("查询成功",data);
    }

    @Override
    public R exportExcel(MaintenanceDataForm maintenanceDataForm) {
        List<MaintenanceDataRecordVo> list = sysWorksheetRecordDao.getMaintenanceExcel(maintenanceDataForm);
        return null;
    }

    @Override
    public R getRecordList(MaintenanceDataForm maintenanceDataForm, Integer page, Integer size) {
        List<MaintenanceDataRecordVo> list = sysWorksheetRecordDao.getMaintenanceRecordList(page, size, maintenanceDataForm);
        Integer total = sysWorksheetRecordDao.getMaintenanceRecordNumber(maintenanceDataForm);
        Map<String,Object> data = new HashMap<>();
        data.put("list",list);
        data.put("total",total);
        data.put("status",sysWorksheetRecordDao.getStatusCount(maintenanceDataForm));
        data.put("type",sysWorksheetRecordDao.getTypeCount(maintenanceDataForm));
        return R.success("查询成功",data);
    }
}
